package com.dhl.stategy.improve;

import com.dhl.stategy.improve.flybehavior.FlyBehavior;
import com.dhl.stategy.improve.quackbehavior.QuackBehavior;

/**
 * @title: Duck
 * @Author danghailiang
 * @Date: 2022/8/24 1:09
 * @Version 1.0
 */
public abstract class Duck {
    /**
     * 聚合会飞的
     */
    private FlyBehavior flyBehavior;
    /**
     * 会叫的
     */
    private QuackBehavior quackBehavior;

    public  void flyBehavior(){
        if(flyBehavior != null ){
            flyBehavior.fly();
        }
    }

    public void quackBehavior(){
        if(quackBehavior != null ){
            quackBehavior.quack();
        }
    }

    public void swim(){
        System.out.println("鸭子会游泳");
    }

    public FlyBehavior getFlyBehavior() {
        return flyBehavior;
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public QuackBehavior getQuackBehavior() {
        return quackBehavior;
    }

    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }

    public abstract void display();
}
